library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
## Linking to GEOS 3.11.2, GDAL 3.6.2, PROJ 9.2.0; sf_use_s2() is TRUE
library(rnaturalearth)
library(countrycode)
library(ggrepel)
library(ggplot2)
library(tmap)
library(gganimate)
## No renderer backend detected. gganimate will default to writing frames to separate files
## Consider installing:
## - the `gifski` package for gif output
## - the `av` package for video output
## and restarting the R session
library(shiny)
#Inputs for maps in tmap
my_map_col<-read.csv("paises_col.csv")
world_shapefile <- ne_download(scale = "large", type = "countries", category = "cultural", returnclass = "sf") %>% filter(ADMIN!="Antarctica") %>%
st_transform(crs="+proj=robin")
world_shapefile_new<-world_shapefile %>%
select(geometry,NAME,ISO_A3,ISO_A3_EH,ADMIN) %>%
left_join(my_map_col,by=c("ISO_A3_EH"="Country")) %>%
rename(all_time=All.time)%>%
pivot_longer(cols=6:19,names_to="year",values_to="visited")%>%
mutate(visited = if_else(is.na(visited), "grey", visited))
Here is a view of all the countries I have visited in my life.
tmap_mode("view")
## tmap mode set to interactive viewing
tmap_options(check.and.fix = TRUE)
world_shapefile_new %>%
filter(year=="all_time")%>%
tm_shape()+
tm_borders()+
tm_fill(col="visited")
## Warning: The shape . is invalid (after reprojection). See sf::st_is_valid